<template>
  <el-header style="text-align: right; font-size: 12px">
    <!-- ============头部查询部分============开始 -->
    <div class="form">
      <el-form :inline="true" :model="menuForm" ref="ruleForm">
        <el-form-item label="菜单名称">
          <el-input
            class="input"
            v-model="menuForm.name"
            type="text"
            size="mini"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="状态">
          <el-select class="input select" v-model="menuForm.status" size="mini" placeholder="全部">
            <el-option value="有效"></el-option>
            <el-option value="无效"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="菜单类型">
          <el-select class="input select" v-model="menuForm.menuType" size="mini" placeholder="全部">
            <el-option value="目录"></el-option>
            <el-option value="菜单"></el-option>
            <el-option value="功能"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item class="allbtn">
          <!-- <a><i class="el-icon-search"></i></a> -->
          <el-button
            class="btn"
            size="mini"
            type="primary"
            icon="el-icon-search"
            @click="selectForm()"
          >查询</el-button>
          <el-button
            class="btn"
            size="mini"
            type="primary"
            icon="el-icon-circle-plus-outline"
            @click="insertMenuList()"
            v-if="$store.state.insertMenuFlag"
          >新增</el-button>
          <el-button
            class="btn"
            size="mini"
            type="primary"
            icon="el-icon-remove-outline"
            @click="deleteList()"
            v-if="$store.state.deleteMenuFlag"
          >删除</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- ============头部查询部分============结束 -->
  </el-header>
</template>
<script>
export default {
  props: ["sendPage", "selections"],
  components: {},
  data() {
    return {
      menuForm: {},
      menuTable: [],
    };
  },
  methods: {
    selectForm() {
      this.$emit("sendSelectMenu", this.menuForm);
    },
    insertMenuList() {
      this.$emit("openDialog", true);
    },
    deleteList() {
      console.log(this.selections);
      const p=new URLSearchParams();
      const menuIds=[]
      for (let i = 0; i < this.selections.length; i++) {
        menuIds.push(this.selections[i].menuId)
      }
      p.append("menuIds",menuIds)
      this.$http
        .get("/menu/deleteMenuList", { params: p })
        .then((res) => {
          console.log(res.data)
          if (res.data > 0) {
            this.$message.success("删除成功");
          } else {
            this.$message.error("删除失败");
          }
        });
        this.$emit("refreshList")
        this.$store.dispatch('findAllMenu')
    },
  },
  mounted() {
    this.$emit("sendSelectMenu", this.menuForm);
  },
};
</script>
<style lang='less' scoped>
.form {
  float: left;
  margin-top: 10px;
}
.el-header {
  /* width: 100%; */
  background-color: #b3c0d1;
  color: #333;
  /* line-height: 60px; */
}
</style>